<!DOCTYPE HTML>
<html>

<head>
    <include file="Public/head" />
</head>

<body>
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        系统设置
        <span class="c-gray en">&gt;</span>
        编辑角色
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
            title="刷新">
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <div class="page-container">
        <form action="{:U('Role/edit')}" method="post" class="form form-horizontal">
            <input type="hidden" value="{$role.id}" name="role_id">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>
                    角色名称：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text" class="input-text" value="{$role.name}" placeholder="" name="product-category-name">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>
                    备注：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text" class="input-text" value="{$role.remark}" placeholder="" name="product-category-name">
                </div>
            </div>
            <div style="width:80%;margin:0px auto;margin-top:30px;">
                选择权限:
                <foreach name="menu_tree" item="vo">
                    <div style="margin-top:10px;border-top:1px solid #ccc;" pid="{$vo.id}">
                        {$vo.name}
                        <input type="checkbox" value="{$vo.id}" onclick="check(this)" name="roleids[]">
                        <notempty name="vo.son">
                            <foreach name="vo.son" item="svo">
                                <div style="padding-left:30px;border-top:1px solid #ccc;" pid="{$svo.id}">
                                    {$svo.name}
                                    <input type="checkbox" value="{$svo.id}" onclick="check(this)" name="roleids[]">
                                    <notempty name="svo.son">
                                        <foreach name="svo.son" item="ssvo">
                                            <div style="padding-left:30px;border-top:1px solid #ccc;" pid="{$ssvo.id}">
                                                {$ssvo.name}
                                                <input type="checkbox" value="{$ssvo.id}" onclick="check(this)" name="roleids[]">
                                            </div>
                                        </foreach>
                                    </notempty>
                                </div>
                            </foreach>
                        </notempty>
                    </div>
                </foreach>
            </div>
            <div class="row cl">
                <div class="col-9 col-offset-2">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
        <include file="Public/script" />
</body>

<script>
    function check(the) {        
        if (the.checked) {
            $("div[pid='" + the.value + "'] input").prop('checked', true);
        } else {
            $("div[pid='" + the.value + "'] input").prop('checked',false);
        }
    }

    var role_menu_json='{$role_menu_json}';
    var role_menu=$.parseJSON(role_menu_json);
    $.each(role_menu,function(key,val){
        $("input[value='" + val['menu_id'] + "']").prop('checked', true);
    })
</script>

</html>